package com.fzshang.shopping.api.controller;


import com.fzshang.shopping.commen.bean.Classification;
import com.fzshang.shopping.commen.bean.ShoppingOrder;
import com.fzshang.shopping.commen.bean.layuiBean.ResultPage;
import com.fzshang.shopping.commen.bean.layuiBean.VoPage;
import com.fzshang.shopping.commen.controller.BaseController;
import com.fzshang.shopping.commen.entity.ApiResult;
import com.fzshang.shopping.commen.util.WL.WL;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 冯政尚
 * @since 2020-03-28
 */
@Controller
@RequestMapping("admin/shoppingOrder")
public class ShoppingOrderController extends BaseController {

    @RequestMapping(value = "shoppingOrder.html")
    public String shoppingOrder(){
        return "admin/order/shoppingOrder";
    }
    @RequestMapping(value = "oddNumber.html")
    public String oddNumber(Model model,Long id){
        model.addAttribute("id",id);
        return "admin/order/oddNumber";
    }
    @RequestMapping(value = "kd.html")
    public String wl(Model model,String kd){
        model.addAttribute("kd",kd);
        return "admin/order/kd";
    }

    /**
     * @param voPage
     * @return 后台查询
     */
    @RequestMapping(value = "selectMyPage",method = RequestMethod.GET)
    @ResponseBody
    public ResultPage<ShoppingOrder> selectMyPage(VoPage voPage, ShoppingOrder shoppingOrder){
        return shoppingOrderService.selectMyPage(voPage,shoppingOrder);
    }

    /**
     * @param shoppingOrder
     * @return 填写快递单号
     */
    @RequestMapping(value = "KDNumber")
    @ResponseBody
    public ApiResult KDNumber(@RequestBody ShoppingOrder shoppingOrder){
        shoppingOrder.setState(6);
        if(shoppingOrderService.updateById(shoppingOrder)){
            return ApiResult.ok();
        }
        return ApiResult.fail();
    }

    /**
     * @param oddNumber
     * @return 物流查询
     */
    @RequestMapping(value = "selectLogisticsExpress")
    @ResponseBody
    public ApiResult selectLogisticsExpress(String oddNumber){
        return WL.getLogisticsExpress(oddNumber);
    }

}
